﻿
// DemoDlg.h: 头文件
//


#pragma once
#include"ConfigIni.h"
#include "GigECam.h"

using namespace cv;
// CDemoDlg 对话框
class CMainDlg : public CDialogEx
{
	// 构造
public:
	CMainDlg(CWnd* pParent = nullptr);	// 标准构造函数

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum
	{
		IDD = IDD_MAIN_DIALOG
	};
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV 支持


// 实现
protected:
	HICON m_hIcon;

	// 生成的消息映射函数
	virtual BOOL OnInitDialog();
	void StartGigeCamAutoLink();
	unsigned int __stdcall GigeCamAutoLink();
	afx_msg
		int EnumCamera();
	void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg LRESULT OnReceiveAndDisplaySystemLog(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
	CMenu m_menu;
public:
	CListCtrl m_LogList;
	circular_buffer<LOG_PACKAGE>   m_logBuffer;
	void SetUiHandle();
	void StartInitThread();
	unsigned __stdcall StartOpenThread();

	virtual void OnCancel();
	void MainDlgInfIniInit();
	CConfigIni m_cMainConfigIni;
	void OnLvnItemchangedListLog(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnNMCustomdrawListLog(NMHDR *pNMHDR, LRESULT *pResult);

private:
	DWORD ThreadID[THREAD_NUM] = { 0 };
	HANDLE ThreadHandle[THREAD_NUM] = { NULL };
public:
	afx_msg void OnOpcTcpip();
	afx_msg void OnCmera();
	afx_msg void OnLogin();
	afx_msg void OnBnClickedButtonStop();
	int OnBnClickedButtonStart();
	unsigned __stdcall StartCamCheckThread();
	void CheckMatch();
	afx_msg void OnBnClickedButtonInit();
	unsigned int __stdcall CamDisplayThread();
	//void ShowImage(Mat & src, UINT ID);
	CComboBox m_comboCamList;
	HBRUSH hbr;//画笔相关


	union UI_Proc
	{
		unsigned(_stdcall * ThreadProc)(void*);
		unsigned(_stdcall CMainDlg::*MemProc)();
	}GlueCheck, ProcStart, CamLink;

	CRect m_rcUiRect;
	CRect OriRect[100];
	int RectW[100] = { 0 };
	int RectH[100] = { 0 };
	char *m_cPath;
	CString m_cstrPath;
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	CButton m_checkMatch;
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnBtnChangeProject();
	void Repaint(CWnd* pWnd, int last_Width, int now_Width, int last_Height, int now_Height, int cnt);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnGlueTest();
	afx_msg void OnBnClickedButtonTestHand();
	void StartGlueCheckMainThread();
	unsigned int __stdcall GlueCheckMainThread();
	BOOL m_bCancleFalg;
	afx_msg void OnBnClickedButton1();
	virtual BOOL PreTranslateMessage(MSG* pMsg);
};

